#include "../common/httplib.h"

int main() 
{
    // 1.实例化一个服务器对象
    httplib::Server server;
    // 2.注册回调函数
    server.Get("/hi", [](const httplib::Request& req, httplib::Response& resp){
        std::cout << "req.method = " << req.method << std::endl;
        std::cout << "req.path = " << req.path << std::endl;
        for(auto it : req.headers) 
        {
            std::cout << it.first << ": " << it.second << std::endl;
        }
        std::string body = "<html><body><h1>Hello World</h1></body></html>";
        resp.set_content(body, "text/html");
        resp.status = 200;
    });
    // 3.启动服务器
    server.listen("0.0.0.0", 8081);

    return 0;
}